home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / util / pack / xpk_Source.lha / xpk_Source / test / testFullPack.c < prev    next >
C/C++ Source or Header  |  1998-11-09  |  3KB  |  118 lines

  1. #define NAME        "testFullPack"
  2. #define DISTRIBUTION    "(Freeware) "
  3. #define REVISION    "2"
  4.  
  5. /* Programmheader
  6.  
  7.     Name:        testFullPack
  8.     Author:        SDI
  9.     Distribution:    Freeware
  10.     Description:    tests all packmodes with all file-sizes to 100000
  11.     Compileropts:    -
  12.     Linkeropts:    -l xpkmaster amiga
  13.  
  14.  1.0   15.05.97 : first version to find IDEA error
  15.  1.1   16.05.97 : changed output format (shorter)
  16.  1.2   17.05.97 : fixed a wrong parameter
  17. */
  18.  
  19. /* This program was developed to find a IDEA bug. It may be used to detect
  20. errors in sub libraries. It calls the specified library with all file sizes
  21. from START to 100000 and in all modes and reports errors. Buffer contents is
  22. an increasing byte value starting with 1. Parameter FILE is used to store a
  23. logfile. This is useful, when library crashes the machine.
  24. */
  25.  
  26. #include <proto/exec.h>
  27. #include <proto/dos.h>
  28. #include <proto/xpkmaster.h>
  29. #include <exec/memory.h>
  30. #include "SDI_defines.h"
  31.  
  32. struct Library        *XpkBase        = 0;
  33. ULONG            DosVersion        = 37;
  34.  
  35. #define PARAM "METHOD,START/N,PASSWORD,FILE,STEP/N"
  36.  
  37. void main(void)
  38. {
  39.   ULONG noth = 1, step = 1;
  40.   struct RDArgs    *rda;
  41.   struct args
  42.   {
  43.     STRPTR method;
  44.     ULONG *start;
  45.     STRPTR password;
  46.     STRPTR file;
  47.     ULONG *step;
  48.   } args = {"IDEA", 0, "TestPwd", "testFullPack.out", 0};
  49.  
  50.   args.start = ¬h;
  51.   args.step = &step;
  52.  
  53.   if((rda = ReadArgs(PARAM, (LONG *) &args, 0)))
  54.   {
  55.     if((XpkBase = OpenLibrary(XPKNAME, 0)))
  56.     {
  57.       STRPTR ibuf;
  58.  
  59.       if((ibuf = (STRPTR) AllocMem(100000, MEMF_CLEAR)))
  60.       {
  61.         STRPTR obuf;
  62.  
  63.         if((obuf = (STRPTR) AllocMem(200000, MEMF_ANY)))
  64.         {
  65.           ULONG fh;
  66.  
  67.       if((fh = Open(args.file, MODE_READWRITE)))
  68.           {
  69.             ULONG i, j, olen;
  70.             LONG err;
  71.  
  72.         Seek(fh, 0, OFFSET_END);
  73.  
  74.         for(i = 0; i < 100000; ++i)
  75.           ibuf[i] = i;
  76.  
  77.             for(i = *args.start; !CTRL_C && i <= 100000; i += *args.step)
  78.             {
  79.               Printf("%6ld: ", i);
  80.               FPrintf(fh, "%6ld: ", i);
  81.               for(j = 0; !CTRL_C && j <= 100; ++j)
  82.               {
  83.                 if((err = XpkPackTags(XPK_InBuf, ibuf, XPK_InLen, i,
  84.                   XPK_PackMethod, args.method, XPK_OutBuf, obuf,
  85.                   XPK_OutBufLen, 200000, XPK_GetOutLen, &olen, XPK_Password,
  86.                   args.password, XPK_PackMode, j, TAG_DONE)))
  87.                   {
  88.                     Printf("p%03ld(%02ld), ", j, -err);
  89.                     FPrintf(fh,"p%03ld(%02ld), ", j, -err);
  90.                   }
  91.                 else if((err = XpkUnpackTags(XPK_InBuf, obuf, XPK_InLen, olen,
  92.                   XPK_OutName, "NIL:", XPK_Password, args.password, TAG_DONE)))
  93.                   {
  94.                     Printf("u%03ld(%02ld), ", j, -err);
  95.                     FPrintf(fh,"u%03ld(%02ld), ", j, -err);
  96.                   }
  97.               }
  98.               if(CTRL_C)
  99.               {
  100.                 Printf("\nbreak:  %03ld", j);
  101.                 FPrintf(fh, "\nbreak:  %03ld", j);
  102.               }
  103.               Printf("\n");
  104.               FPrintf(fh, "\n");
  105.             }
  106.             Close(fh);
  107.           }
  108.           FreeMem(obuf, 200000);
  109.         }
  110.         FreeMem(ibuf, 100000);
  111.       }
  112.       CloseLibrary(XpkBase);
  113.     }
  114.     FreeArgs(rda);
  115.   }
  116. }
  117.  
  118.